package com.snopy.designPattern.structure.bridge.impl;

import com.snopy.designPattern.structure.bridge.inter.Device;
import com.snopy.designPattern.structure.bridge.inter.Remote;

/**
 * @author snopy
 * @version 1.0.0
 * @classname BasicRemote
 * @description
 * @email 77912204@qq.com
 * @date 2022/11/26 21:52
 */
public class BasicRemote implements Remote {

    protected Device device;

    public BasicRemote() {
    }

    public BasicRemote(Device device) {
        this.device = device;
    }

    @Override
    public void power() {
        if (device.isEnabled()){
            device.disabled();
        }else {
            device.enabled();
        }
    }

    @Override
    public void volumeDown() {
        System.out.println("Remote: volume down");
        device.setVolume(device.getVolume() - 1);
    }

    @Override
    public void volumeUp() {
        System.out.println("Remote: volume up");
        device.setVolume(device.getVolume() + 1);
    }

    @Override
    public void channelDown() {
        System.out.println("Remote: channel down");
        device.setChannel(device.getChannel() - 1);
    }

    @Override
    public void channelUp() {
        System.out.println("Remote: channel up");
        device.setChannel(device.getChannel() + 1);
    }
}
